﻿Imports System.Collections.Generic

Partial Class Controls_wctlPersonalSeleccionar
    Inherits System.Web.UI.UserControl
    Dim cBLPersonal As New BLGestionProyecto.BLGPPersonal

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            Try
                cboCategoria.DataSource = cBLPersonal.fuBLListarCategoria()
                cboCategoria.ValueField = "catcodCategoria"
                cboCategoria.TextField = "catdesCategoria"
                cboCategoria.DataBind()

                cboCategoria.Text = Session("CategoriaRequerimiento")
                cboFechaInicio.Text = Session("FechaInicio")
                cboFechaFin.Text = Session("FechaFin")
            Catch ex As Exception
                lblmensaje.Text = Err.Description
            End Try
        End If
    End Sub

    Protected Sub btnConsultar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnConsultar.Click
        dgvPersonasDisponibles.DataBind()
    End Sub

    Protected Sub btnAceptar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAceptar.Click
        Try
            If Not fuValidarDatos() Then
                Exit Sub
            End If
            Dim lLst As List(Of Object) = dgvPersonasDisponibles.GetSelectedFieldValues("percodPersona")
            Dim personalID As String = lLst.Item(0).ToString
            'Session("CategoriaRequerimiento") = categoriaDescripcion
            'Session("FechaInicio") = cboFechaInicio.Text
            'Session("FechaFin") = cboFechaFin.Text
            Response.Redirect("wfrmPersonalDisponibilidadListar.aspx")
        Catch ex As Exception
            lblmensaje.Text = Err.Description
        End Try


    End Sub
    Function fuValidarDatos() As Boolean
        Dim lbErr As Boolean
        Try
            lblmensaje.Text = ""
            If dgvPersonasDisponibles.GetSelectedFieldValues("prycodProyecto").Count = 0 Then
                lblmensaje.Text &= "* Debe seleccionar un Personal de la lista </BR>"
                lbErr = True
            End If
            Return Not lbErr
        Catch ex As Exception
            lblmensaje.Text = Err.Description
        End Try
    End Function
    Protected Sub btnCancelar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCancelar.Click
        Response.Redirect("wfrmProyectoPersonalAsignar.aspx")
    End Sub
End Class
